774G - Perfectionist Arkadiy - CodeForces Solution


*special problem number theory *2700

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<array>
//#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 200005;
const int mod = 998244353;
typedef pair<int, int> pii;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
const double eps = 1e-6;
int main() {
	int a, h, w;
	cin >> a >> h >> w;
	if (a > h || a > w) {
		cout << -1 << endl;
		return 0;
	}
	double g = gcd(a + h, w + a);
	double y = floor(g * 1.0 / a);
	if ( abs(y) <= eps) {
		cout << -1 << endl;
	}
	else {
		double x = g / y - a;
		printf("%.6llf\n", x);
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum